import BaseService from './_BaseService'
import axios from 'axios'
import config from '../config'

class TaskObjectService extends BaseService {
  root = window.apiPath + '/tasks';
  // search (query) {
  //   return super.search(query).then(res => {
  //     return res
  //   })
  // }
  update (entity, operate = ''){
    return axios.put(config.SERVER_URL + this.root + `?operate=${operate}`, {...entity, responseType: 'json'})
      .then(resp => resp.data)
  }
  // create (entity){
  //   return super.create(entity).then(res => {
  //     return res
  //   })
  // }
  criteriaQueries (page, query, pageSize = config.PAGE_SIZE) {
    return axios.get(config.SERVER_URL + this.root + `-filter?page=${page}&size=${pageSize}${query ? '&' : ''}${query}`, {responseType: 'json'})
      .then(resp => resp)
  }
  receive (page = 0, query = '', pageSize = config.PAGE_SIZE) {
    return axios.get(config.SERVER_URL + this.root + `-receive-ps?page=${page}&size=${pageSize}&query=${query}`, {responseType: 'json'})
      .then(resp => resp)
  }
  statistics (entity) {
    return axios.post(config.SERVER_URL + window.apiPath + '/tasks/statistics', {...entity, responseType: 'json'})
      .then(resp => resp)
  }
  // delete (id){
  //   return super.delete(id).then(res => {
  //     return res
  //   })
  // }
  //
  ps (page, query, size) {
    return super.ps(page, query, size).then(res => {
      return res
    })
  }
}

export default new TaskObjectService()
